package com.gitee.freakchicken.dbapi.basic.controller;

import com.gitee.freakchicken.dbapi.basic.domain.User;
import com.gitee.freakchicken.dbapi.basic.service.C_TuHnmjxN;
import com.gitee.freakchicken.dbapi.basic.util.C_QqMwqBsa;
import com.gitee.freakchicken.dbapi.common.ResponseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class C_cmqG5ZAc {

    @Autowired
    C_TuHnmjxN gf_57LXhRwd;

    @RequestMapping("/login")
    public ResponseDto m_Rx66uKfH(String username, String password) {
        User lf_6wHiOXco = gf_57LXhRwd.m_z0q5i6fA(username, password);
        if (lf_6wHiOXco == null) {
            return ResponseDto.fail("Username or password incorrect!");
        } else {
            String lf_8zPXuYnA = C_QqMwqBsa.m_kLtm7cZ7(lf_6wHiOXco.getId().toString(), lf_6wHiOXco.getPassword());
            lf_6wHiOXco.setToken(lf_8zPXuYnA);
            return ResponseDto.successWithData(lf_6wHiOXco);
        }
    }

    @RequestMapping("/resetPassword")
    public ResponseDto m_rquzPMEA(String userId, String oldPassword, String newPassword) {
        return gf_57LXhRwd.m_gkyNwZEk(userId, oldPassword, newPassword);
    }
}
